﻿using Application.Dto;
using Application.IAppSrevices;
using AutoMapper;
using Domain.Entitys;
using Domain.Repositorys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.AppSrevices
{
    public class CFTKService : ICFTKService
    {
        private readonly ICFTKRepository cFTKRepository;
        private readonly IMapper mapper;

        public CFTKService(ICFTKRepository cFTKRepository, IMapper mapper)
        {
            this.cFTKRepository = cFTKRepository;
            this.mapper = mapper;
        }

        /// <summary>
        /// 级联显示下拉框数据
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Cascader> Cascaders()
        {
            return cFTKRepository.Cascaders();
        }

        /// <summary>
        /// 级联显示下拉框数据2
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Cascader> Cascaders2()
        {
            return cFTKRepository.Cascaders2();
        }

        /// <summary>
        /// 删除3级机构表数据
        /// </summary>
        /// <param name="cFTKDeleteDao"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> CFTKDeleteAsync(CFTKDeleteDao cFTKDeleteDao)
        {
            CFTK cFTK = mapper.Map<CFTK>(cFTKDeleteDao);
            return await cFTKRepository.CFTKDeleteAsync(cFTK);
        }

        /// <summary>
        /// 添加3级机构表数据
        /// </summary>
        /// <param name="cFTK"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> CFTKInsertAsync(CFTKAddDto cFTKAddDto)
        {
            CFTK cFTK = mapper.Map<CFTK>(cFTKAddDto);
            //Random random = new Random();
            //int randomPart = random.Next(10000, 100000);
            //long number = 3353318900000L + randomPart;
            //cFTK.ThirdKindId = number.ToString();
            return cFTKRepository.CFTKInsertAsync(cFTK);
        }

        /// <summary>
        /// 根据3级编号查询对应数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<CFTK> CFTKSelectByCftid(string id)
        {
            return cFTKRepository.CFTKSelectByCftid(id);
        }

        /// <summary>
        /// 按id查询对应数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<CFTK> CFTKSelectById(int id)
        {
            return await cFTKRepository.CFTKSelectById(id);
        }

        public async Task<List<CFTK>> CFTKSelectCFSKCFFKId(string sid, string fid)
        {
            return await cFTKRepository.CFTKSelectCFSKCFFKId(sid, fid);
        }

        /// <summary>
        /// 分页查询3级机构表数据
        /// </summary>
        /// <param name="fenYe"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public FenYe<CFTK> CFTKSelectFenYe(FenYe<CFTK> fenYe)
        {
            return cFTKRepository.CFTKSelectFenYe(fenYe);
        }

        /// <summary>
        /// 修改3级结构表数据
        /// </summary>
        /// <param name="cFTK"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> CFTKUpdateAsync(CFTK cFTK)
        {
            return await cFTKRepository.CFTKUpdateAsync(cFTK);
        }

        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<CFTK>> CKTKselectAsync()
        {
            return await cFTKRepository.CKTKselectAsyns();
        }
        public async Task<List<Cascader>> GetCFFKCFSKCFTK()
        {
            return await cFTKRepository.GetCFFKCFSKCFTK();
        }
    }
}
